package com.az.emailcommon.config;

import com.az.emailcommon.util.EmailSender;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;

@Configuration
public class EmailConfig {

    @Value("${spring.mail.username}")
    private String emailFrom;

    @Bean
    public EmailSender emailSenderConfig(JavaMailSender javaMailSender) {
        EmailSender emailSender = EmailSender.getInstance();
        emailSender.setJavaMailSender(javaMailSender);
        emailSender.setEmailFrom(emailFrom);
        return emailSender;
    }
}
